/*
 ============================================================================
 Page	     : 452-453
 Name        : funds2.c
 Date	     : 20210407
 Author      : Hbue 18060333
 Copyright   : Your copyright notice
 Description : 传递指向结构的指针
 ============================================================================
 */

#include <stdio.h>
#define FUNDLEN 50

struct funds
{
	char bank[FUNDLEN];
	double bankfund;
	char save[FUNDLEN];
	double savefund;
};

double sum(const struct funds *);		/* 参数是一个指针 */

int main(void)
{
	struct funds stan = {
			"Garlic-Melon Bank",
			4032.27,
			"Lucky's Saving and Loan",
			8543.94
	};

	printf("Stan has a total of $%.2f.\n", sum(&stan));

	return 0;
}

/* 两个double类型的数相加 */
double sum(const struct funds * money)
{
	return (money->bankfund + money->savefund);
}

